let winObjIndex = {}

function waitObj(winObj) {
	return new Promise(function(resolve) {
		return setTimeout(() => {
			if (window[winObj]) {
				log(`动态加载对象成功[${winObj}]`);
				resolve(window[winObj]);
				return;
			}
			winObjIndex[winObj] = (winObjIndex[winObj] || 0) + 1
			console.log(`动态加载对象[{}], 第{}次尝试...`, winObj, winObjIndex[winObj]);
			if (winObjIndex[winObj] > 4) {
				console.log('等待对象加载失败，可能是因为网络超时-', winObj)
				return;
			}
			waitObj(winObj).then(() => resolve(window[winObj]));
		}, 1000);
	});
}

const UtilWaitObj = {
	waitObj
}

export default UtilWaitObj
